﻿using System;

namespace Chip8.Core.Processor.Operations
{
	internal class CALL : Operation
	{
		public CALL(ushort targetAddress)
		{
			TargetAddress = targetAddress;
		}

		public ushort TargetAddress { get; set; }

		public override void Execute(ICPU cpu)
		{
			var returnAddress = cpu.PC + Chip8.OpcodeSize;
			cpu.Stack.Push((ushort)returnAddress);
			cpu.PC = TargetAddress;
		}
	}
}
